LGF_SmoothByPolynomFB (FB / V3.0.1)


Author: Siemens Digital Industry

Short description

This function calculates the smoothed values by polynomial cyclically.

For smoothing, a 3rd degree polynomial is placed through five value points. The error squares of the distances between polynomial and real value are minimized. The smoothed values can be determined from the polynomial parameters obtained in this way.

The function reads-in a value with each positive edge on the insert input. As soon as five values have been read in, the block calculates a smoothed value and outputs it.

Block Interface

LGF_SmoothByPolynomFB (FB)
Bool  enable smoothedValue  LReal
    
Bool  insert error  Bool
    
LReal  value status  Word
    
   

Input parameter

IdentifierData typeDefault valueDescription
enableBoolFALSEActivates the block. As long as enable is `TRUE`, the block can accept values on the parameter `value`.
insertBoolFALSEAccepts the value at the input `value` at positive edge and outputs a `smoothedValue` if five values have been read in.
valueLReal0.0Value that is to be included in the smoothing.

Output parameter

IdentifierData typeDescription
smoothedValueLRealThe smoothed value.
errorBoolFALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)

Status & Error codes

Code / ValueIdentifier / Description
16#7000STATUS_NO_CALL
Status: No call of FB. The block waits for activation through the parameter `enable`.
16#7001STATUS_FIRST_CALL
Status: First call of FB after enabling
16#7002STATUS_SUBSEQUENT_CALL
Status: Processing is active. Subsequent call of FB.
16#7010STATUS_NOT_ENOUGH_VALUES
Status: Not enough values. The block requires five (5) values to calculate a smoothed value. Transfer additional values with a positive edge on the `insert` input.

Functional description

The 3rd degree compensation polynomial is calculated as follows:

\overline{y(n)} = \frac{1}{35} \cdot (-3 \cdot y(n-2) +12 \cdot y(n-1) +17 \cdot y(n) +12 \cdot y(n+1) -3 \cdot y(n+2))

N-4 smoothed measured values can thus be calculated from the N measured values. The output array contains the value 0 in the index (0.1, N-1, N).

These “missing” values are calculated with the following formalisms:

\overline{y(n-2)} = \frac{1}{70} \cdot (69 \cdot y(n-2) +4 \cdot y(n-1) -6 \cdot y(n) +4 \cdot y(n+1) -y(n+2)) \overline{y(n-1)} = \frac{2}{70} \cdot (2 \cdot y(n-2) +27 \cdot y(n-1) +12 \cdot y(n) -8 \cdot y(n+1) +2 \cdot y(n+2)) \overline{y(n+1)} = \frac{2}{70} \cdot (2 \cdot y(n-2) -8 \cdot y(n-1) +12 \cdot y(n) +27 \cdot y(n+1) +2 \cdot y(n+2)) \overline{y(n+2)} = \frac{1}{70} \cdot (-y(n-2) +4 \cdot y(n-1) -6 \cdot y(n) +4 \cdot y(n+1) +69 \cdot y(n+2))

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
23.11.2018First released version
01.00.01Simatic Systems Support
05.11.2019Bugfixes, regions, comments and constants are added
03.00.00Simatic Systems Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
06.04.2021Insert documentation